import Base from '../../static/js/base'
class ProductDetail extends Base{
	constructor() {
		super();
	}
	//商品详情
	product_info(id,callBack) {
		var that = this;
		var params = {
		  url: 'index/product_info',
		  data:{id:id},
		  sCallBack: function (res) {
			callBack && callBack(res.data);
		  }
		};
		that.request(params);
	};
	//商品收藏
	product_collect(id,callBack) {
		var that = this;
		var params = {
		  url: 'index/product_collect',
		  data:{id:id},
		  method:'POST',
		  sCallBack: function (res) {
			callBack && callBack(res.data);
		  }
		};
		that.request(params);
	};
	//加入购物车
	add_cart(data,callBack) {
		var that = this;
		var params = {
		  url: 'cart/add_cart',
		  data:data,
		  method:'POST',
		  sCallBack: function (res) {
			callBack && callBack(res.data);
		  }
		};
		that.request(params);
	};
	//商品详情立即购买
	add_product_order(data,callBack) {
		var that = this;
		var params = {
		  url: 'order/add_product_order',
		  data:data,
		  method:'POST',
		  sCallBack: function (res) {
			callBack && callBack(res.data);
		  }
		};
		that.request(params);
	};
	//当前选择商品的详情
	sku_str(that){
		if(that.product_info_list.specs_status == 1){
			that.sku_str = '';
			for(var i=0;i<that.sku.length;i++){
				that.sku_str = that.sku_str + that.product_info_list.attrbute_list[i].name + '：';
				for(var j=0;j<that.product_info_list.attrbute_list[i].sub.length;j++){
					if(that.sku[i] == that.product_info_list.attrbute_list[i].sub[j].id){
						that.sku_str = that.sku_str + that.product_info_list.attrbute_list[i].sub[j].name + '，';
					}
				} 
			}
		}
	};
	//获取收货地址
	get_user_site(callBack) {
		var that = this;
		var params = {
		  url: 'site/get_user_site',
		  sCallBack: function (res) {
			callBack && callBack(res.data);
		  }
		};
		that.request(params);
	};
}

export default ProductDetail	